import { Table, DataSet } from 'choerodon-ui/pro';
import React, { useMemo } from 'react';
import {
  ColumnLock,
  ColumnAlign,
  TableButtonType,
  TableCommandType,
  TableEditMode,
} from 'choerodon-ui/pro/lib/table/enum';

import getTableDSProps from './tableDataSet';

const TableList: React.FC = () => {
  const tableDs = useMemo(() => new DataSet(getTableDSProps()), []);
  return (
    <Table
      dataSet={tableDs}
      editMode={TableEditMode.inline}
      buttons={[TableButtonType.delete]}
      queryFieldsLimit={2}
      columns={[
        {
          name: 'userid',
          editor: true,
        },
        {
          name: 'age',
          editor: true,
        },
        {
          name: 'enable',
          editor: true,
        },
        {
          name: 'name',
          editor: true,
        },
        {
          header: '操作',
          align: ColumnAlign.center,
          command: [TableCommandType.edit],
          lock: ColumnLock.right,
        },
      ]}
    />
  );
};

export default TableList;
